import 'package:flutter/material.dart';
import 'package:flutter_project/config/common_string_config.dart';
import 'package:flutter_project/generated/l10n.dart';
import 'package:flutter_project/picture/works_tab_list_page.dart';
import 'package:get/get.dart';

class MyWorkTabPage extends StatefulWidget {
  const MyWorkTabPage({super.key});

  @override
  State<MyWorkTabPage> createState() => _MyWorkTabPageState();
}

class _MyWorkTabPageState extends State<MyWorkTabPage>
    with SingleTickerProviderStateMixin {
  late TabController importTabController;
  List<String> tabList = ['视频', '图片'];
  double tabFontSize = 16.0;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        SizedBox(
          height: 40,
          child: TabBar(
            dividerHeight: 0.0,
            tabs: getTabList(),
            controller: importTabController,
            // labelColor: ThemeColor.black3D3D3DColor,
            // unselectedLabelColor: ThemeColor.grayA0A0A0Color,
            indicatorSize: TabBarIndicatorSize.label,
            // indicatorColor: ThemeColor.appColor,
            unselectedLabelStyle: TextStyle(
              fontSize: tabFontSize,
            ),
            // 未选择样式
            labelStyle: TextStyle(
                fontSize: tabFontSize, fontWeight: FontWeight.w500), // 选择的样式
          ),
        ),
        Expanded(
          child: TabBarView(controller: importTabController, children: const [
            WorksTabListPage(
              type: CommonEditType.videoType,
            ), //1代表视频  0是图片
            WorksTabListPage(
              type: CommonEditType.imgType,
            ),
          ]),
        ),
      ],
    );
  }

  //组装tab
  List<Widget> getTabList() {
    List<Widget> list =
        List.generate(tabList.length, (index) => Tab(text: tabList[index]));
    return list;
  }

  @override
  void initState() {
    super.initState();
    tabList = [S.of(Get.context!).video, S.of(Get.context!).picture];
    importTabController = TabController(length: tabList.length, vsync: this);
  }

  @override
  void dispose() {
    importTabController.dispose();
    super.dispose();
  }
}
